package com.dibang.app.operation.view.impl;

import android.support.annotation.NonNull;
import android.widget.TextView;

import com.dibang.app.R;
import com.dibang.app.mvp.abs.AbsView;
import com.dibang.app.operation.control.abs.LoginSmsControl;
import com.dibang.app.operation.model.abs.LoginSmsModel;
import com.dibang.app.operation.presenter.abs.LoginSmsPresenter;
import com.dibang.app.operation.view.abs.LoginSmsView;
import com.dibang.app.view.CountDownTextView;
import com.dibang.app.view.ViewHelper;

import java.util.concurrent.TimeUnit;

/**
 * Created by wxl on 2019/7/19.
 * 验证码登录view层
 */

public class LoginSmsViewImpl extends AbsView<LoginSmsControl,LoginSmsView,LoginSmsPresenter,LoginSmsModel> implements LoginSmsView {


    @Override
    public void onCountDownTimeViewExpandAndStart(@NonNull CountDownTextView tickView,@NonNull TextView mobileView) {
        tickView.setNormalText("发送验证码")
                .setCountDownText("", "s后重发")
                .setCloseKeepCountDown(false)//关闭页面保持倒计时开关
                .setCountDownClickable(false)//倒计时期间点击事件是否生效开关
                .setShowFormatTime(false)//是否格式化时间
                .setIntervalUnit(TimeUnit.SECONDS)
                .setOnCountDownStartListener(() -> {
                    tickView.setTextColor(ViewHelper.getResColor(tickView.getContext(), R.color.gray_text_color));
                })
                .setOnCountDownFinishListener(() -> {
                    tickView.setTextColor(ViewHelper.getResColor(tickView.getContext(), android.R.color.black));
                })
                .setOnClickListener(v -> tickView.startCountDown(60));
        tickView.startCountDown(60);
    }



}
